package org.kaindorf.kainflix.metadata.repository.entity;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@XStreamAlias("metadata")
@Table(uniqueConstraints = {
    @UniqueConstraint(columnNames = {"productId", "indentifier"}) // only one metadata per product per indentifier
})
public class MetaData implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    
    private Long id;

    @Column
    private Long productId;

    @Column
    private String indentifier;

    @Column(name = "dataValue") // had to be renamed for db because value is a reserved keyword
    private String value;

    public MetaData() {
    }

    public MetaData(Long productId, String indentifier, String value) {
        this.productId = productId;
        this.indentifier = indentifier;
        this.value = value;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public String getIndentifier() {
        return indentifier;
    }

    public void setIndentifier(String indentifier) {
        this.indentifier = indentifier;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}
